Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Fix numpy version to below 2.0 #1059

Merged
merged 3 commits into from
Sep 6, 2024
Merged

CI: Fix numpy version to below 2.0 #1059

merged 3 commits into from
Sep 6, 2024

Conversation

BenjaminBossan
Copy link
Collaborator

@BenjaminBossan BenjaminBossan commented Jun 17, 2024

Pin numpy to < v2.0.0, as only PyTorch 2.3 and higher support it.

@BenjaminBossan
Copy link
Collaborator Author

BenjaminBossan commented Jun 17, 2024

So tests with Python 3.9+ are failing with:

skorch/tests/conftest.py:163: in
import wandb
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/wandb/init.py:27: in
from wandb import sdk as wandb_sdk
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/wandb/sdk/init.py:25: in
from .artifacts.artifact import Artifact
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/wandb/sdk/artifacts/artifact.py:45: in
from wandb import data_types, env, util
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/wandb/data_types.py:32: in
from .sdk.data_types import _dtypes
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/wandb/sdk/data_types/dtypes.py:393: in
NumberType.types.append(np.float
)
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/numpy/init.py:397: in getattr
raise AttributeError(
E AttributeError: np.float_ was removed in the NumPy 2.0 release. Use np.float64 instead.

This comes from wandb, which doesn't work with numpy 2.0: https://github.com/wandb/wandb/issues => 7810. There isn't much we can do from the skorch side, but this should only wandb users, who should pin to numpy v1.26.

I'll keep this PR open for now and will re-trigger once wandb releases a fix. If that takes too long, we can pin numpy for our CI.

@BenjaminBossan
Copy link
Collaborator Author

BenjaminBossan commented Jun 18, 2024

Update: wandb has released a fix. Now encountering a different error on Windows and MacOS:

RuntimeError: Numpy is not available

PyTorch team has been made aware of the issue: https://github.com/pytorch/pytorch/issues => 128860

Edit: According to this comment, the numpy 2.0 fix for PyTorch will not be backported to PyTorch versions below 2.3. Since we want to test those versions, though, there isn't really a choice but to use numpy < v2.0. As soon as we drop official support for versions below 2.3, we can remove the pin.

@BenjaminBossan
Copy link
Collaborator Author

The numpy issues still seem to persist, as can for instance be seen here: https://github.com/skorch-dev/skorch/actions/runs/10682583044/job/29744698675?pr=1064. All runs using either Python > 3.8 and PyTorch < 2.3 fail, as they'll use numpy > 2.0, which is incompatible with the respective PyTorch versions.

The numpy issue was gone intermittently. I think that was because one of the dependencies (possibly accelerate) had pinned it. Now that the pin is gone, the issues resurface. But either way, we should not depend on another dependency to do the pinning for us.

ping @ottonemo @thomasjpfan

@BenjaminBossan BenjaminBossan changed the title CI: Empty commit to trigger CI with newly released numpy 2.0 CI: Fix numpy version to below 2.0 Sep 6, 2024
@ottonemo ottonemo merged commit 9252477 into master Sep 6, 2024
15 checks passed
@BenjaminBossan BenjaminBossan deleted the ci-testing-numpy-2.0 branch September 6, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants